package com.sayimo.maker.base.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import com.sayimo.framework.exception.DaoException;
import com.sayimo.framework.exception.ServiceException;
import com.sayimo.maker.base.dao.BasePhotoInterfaceDao;
import com.sayimo.maker.base.service.BasePhotoService;
import com.sayimo.maker.base.vo.BasePhoto;
import com.sayimo.maker.commons.Constant;
import com.sayimo.maker.commons.MessageVo;



/**
 * @Copyright (c) 2015 广东省尚一互联网有限公司
 * @Project: schoolmallapi
 * @ClassName: BasePhotoServiceImpl
 * @Description: 
 * @Author:	chenpy
 * @Date:	日期：2015年12月29日  时间：上午10:43:04
 * @Version 1.0.0
 */
@Service(value = "basePhotoServiceImpl")
public class BasePhotoServiceImpl implements BasePhotoService {
		
	private static Log logger = LogFactory.getLog(BasePhotoServiceImpl.class);
	
	@Resource(name="basePhotoDao")
	private BasePhotoInterfaceDao basePhotoDao;
	
	/* (non-Javadoc)
	 * @see com.sayimo.school.mall.module.admin.service.BasePhotoService#insertBasePhoto(com.sayimo.school.mall.module.admin.model.BasePhoto)
	 */
	public MessageVo insertBasePhoto(BasePhoto basePhoto) throws ServiceException {
		MessageVo messageVo = new MessageVo();
		try {
			int result = basePhotoDao.insertBasePhoto(basePhoto);
			if (result > 0) {
				messageVo.setCode(Constant.SUCCESS);
				messageVo.setMsg(String.valueOf(basePhoto.getId()));
				return messageVo;
			}
			messageVo.setCode(Constant.ERROR);
			return messageVo;
		} catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	/* (non-Javadoc)
	 * @see com.sayimo.school.mall.module.admin.service.BasePhotoService#selectAllById(java.lang.String)
	 */
	public List<BasePhoto> selectAllById(String ids) throws ServiceException {
		try {
			return this.basePhotoDao.selectAllById(ids);
		} catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	/* (non-Javadoc)
	 * @see com.sayimo.school.mall.module.admin.service.BasePhotoService#selectBasePhotoId(java.lang.Integer)
	 */
	public BasePhoto selectBasePhotoId(Integer id) throws ServiceException {
		try {
			return this.basePhotoDao.selectBasePhotoId(id);
		} catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public BasePhotoInterfaceDao getBasePhotoDao() {
		return basePhotoDao;
	}

	public void setBasePhotoDao(BasePhotoInterfaceDao basePhotoDao) {
		this.basePhotoDao = basePhotoDao;
	}
}
